<?

class DB
{
	private $dbh;

	public function __construct()
	{
        require('config.php');
		try {
			$this->dbh = new PDO('mysql:host='.$mysql_host.';dbname='.$mysql_dbname, $mysql_username, $mysql_password);	
		} catch (PDOException $e) {
            global $IRIS_VERSION;
            echo '<html><head><title>IRIS: Database Error</title></head>';
            echo '<body>';
            echo '<center><h1>mySQL Connection Error</h1>';
            echo 'There was a problem connecting to your mySQL database.<br />';
            echo 'Please check the <code>config.php</code> file in your IRIS installation directory.<br /><br />';
		    echo '<span style="font-size: smaller;">Error Details: '.$e->getMessage().'</span>';
            echo '<hr />';
            echo '<span style="font-size: smaller;">IRIS Version: '.$IRIS_VERSION.'</span>';
            echo '</center></body></html>';
		   die();
		}		
		$this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);		
	}

	public function getDB()
	{
		return $this->dbh;
	}
}

?>
